package main

import (
	"fmt"
	"reflect"
)

type Student struct {
	Name string
	Age  int
}

func main() {
	var stu Student = Student{
		Name: "nnn",
		Age:  18,
	}
	//marshal, err := json.Marshal(stu)
	//if err != nil {
	//	fmt.Println()
	//}
	//fmt.Println(string(marshal))
	////fmt.Println(marshal)
	//var stud Student
	//err = json.Unmarshal(marshal, &stud)
	//fmt.Println(stud)
	ref(stu)
}
func ref(T interface{}) {
	Type := reflect.TypeOf(T)
	fmt.Println(Type)
	//fmt.Println(Type.Field(0))
	value := reflect.ValueOf(T)
	//fmt.Println(value)
	fmt.Println(value.Kind())
	//v := value(Student)
	fmt.Println(value.Field(1))
	value.NumField()
	value.Int()
	i := value.Interface()
	student := i.(Student)
	fmt.Println(student)
	value.Elem() //获取指针对象的值
	//value.Call()
}
